#include <iostream>
#include "XML.h"
#include "Document.h"

#include <QCoreApplication>
#include <QDebug>


using namespace xml;

void WriteXML();
void ReadXML();

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    //WriteXML();
    ReadXML();
    return a.exec();

}


void WriteXML(){
    Document    document;

    Element     root    =   Element("RootElement");


    Element     book        =   Element("Book");
    Element     bookTitle   =   Element("Title");
    Element     bookAuthor  =   Element("Author");
    Element     bookDate    =   Element("DatePublication");

    root.AppendChild(book);

    book.AppendChild(bookTitle);
    book.AppendChild(bookAuthor);
    book.AppendChild(bookDate);

    bookTitle.AppendText("Alice in wonderland");
    bookAuthor.AppendText("LewisCaroll");
    bookDate.AppendText("1874");


    Element comments    =   Element("Comments");
    Element comment     =   Element("Comment");

    Element commentTitle    =   Element("Title");
    Element commentAuthor   =   Element("Author");
    Element commentText     =   Element("Text");

    book.AppendChild(comments);
    comments.AppendChild(comment);

    comment.AppendChild(commentTitle);
    comment.AppendChild(commentAuthor);
    comment.AppendChild(commentText);

    commentTitle.AppendText("First");
    commentAuthor.AppendText("Darkikoulol83");
    commentText.AppendText("Fiiiiiiiiiiiiiiirrrsssstt lol xDdddddd!");

    document.m_Root =   &root;
    document.Save("C:/Workbench/MachinBidule.xml");
}

void ReadXML(){
    Document document=Document("C:/Workbench/MachinBidule.xml");
    document.Print();
}
